﻿@using DirectSell.Model.Manager
@using Webdiyer.WebControls.Mvc;
@model PagedList<Managers>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Manager/Views/Shared/ManagerLayout.cshtml";
}

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员中心 <span class="c-gray en">&gt;</span> 管理员管理 
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="#" onclick='$("#searchForm").submit();' title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray"> <span class="l"> 
         <a class="btn btn-primary radius" href="javascript:;" onclick="admin_role_add('添加管理员','/Manager/Admin/AdminAdd','800')"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a></span> </div>

    @using (Ajax.BeginForm("Index", new RouteValueDictionary { { "id", "" } }, new AjaxOptions { UpdateTargetId = "articles", InsertionMode = InsertionMode.Replace }, new RouteValueDictionary { { "id", "searchForm" } }))
    {
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="输入管理员姓名或编号" id="" name="SerachCondition">
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜管理员</button>
        </div>
    }
    <div class="mt-20" style="text-align:center">
        <div id="articles">
            @Html.Partial("_AjaxSearchPost", Model)
        </div>
    </div>
</div>
@section Scripts
{
    @{Html.RegisterMvcPagerScriptResource();}
}
<script type="text/javascript">
    /*管理员-添加*/
    function admin_role_add(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*用户-编辑*/
    function member_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    function Delete(id) {
        //询问框
        layer.confirm('确定要删除该管理员吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            //加载层
            var index = layer.load(1, {
                shade: [0.1, '#fff']
            });
            $.ajax({
                type: "post",
                url: "/Manager/Admin/Delete",
                data: { id: id },
            }).success(function (message) {
                if (message == "最后的管理员不能删除了") {
                    layer.msg(message, { icon: 2 });
                    return;
                }
                layer.msg(message, { icon: 1 });
                $("#searchForm").submit();
            }).fail(function (err) {
                layer.msg('系统错误,请稍后重试', { icon: 2 });
            })
            layer.close(index)//关闭加载层
        });
    }
</script>
